package com.lonwan.demo.exception;

import com.lonwan.demo.util.ResultHelper;
import com.lonwan.demo.vo.CommonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author susc
 * @title: ExceptionAdvice
 * @projectName knife4j-demo
 * @description: TODO
 * @date 2021/9/2915:30
 */
@RestControllerAdvice
@Slf4j
public class ExceptionAdvice {

    @ExceptionHandler(value = Exception.class)
    public CommonResult<String> globalException(Exception e){
      log.info(e.getMessage(), e);
      return ResultHelper.error(e.getMessage());
    }
}
